package com.hand.hzero.api.controller.v1;

import com.hand.hzero.config.SwaggerTags;
import io.choerodon.swagger.annotation.Permission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.bouncycastle.cert.ocsp.Req;
import org.hzero.boot.platform.profile.ProfileClient;
import org.hzero.core.util.Results;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 *
 * </p>
 *
 * @author hand-wd
 */
@Api(tags = SwaggerTags.EXAMPLE)
@RestController("profileClientController.v1")
@RequestMapping("/v1/profile/client")
public class ProfileClientController {
    @Resource
    private ProfileClient profileClient;

    @ApiOperation(value = "根据配置编码获取当前用户最低层次的配置维护值")
    @Permission(permissionLogin = true)
    @GetMapping("/get-profile/{profileName}")
    public ResponseEntity<String> getProfileValueByOptions(@PathVariable("profileName") String profileName) {
        String op = profileClient.getProfileValueByOptions(profileName);
        return Results.success(op);
    }

    @ApiOperation(value = "根据租户id，用户id,角色id，配置维护名获取当前用户最低层次的配置维护值")
    @Permission(permissionLogin = true)
    @GetMapping("/get-profile")
    public ResponseEntity<String> getProfileValueByOptions1(@RequestParam(value = "tenantId", required = false) Long tenantId,
                                                            @RequestParam(value = "userId", required = false) Long userId,
                                                            @RequestParam(value = "roleId", required = false) Long roleId,
                                                            @RequestParam(value = "profileName", required = false) String profileName) {
        String op = profileClient.getProfileValueByOptions(tenantId, userId, roleId, profileName);
        return Results.success(op);
    }
}
